﻿CREATE PROCEDURE Security.SaveUserRoles
(
	@UserID		bigint,
	@Roles		varchar(250)
)
AS 
BEGIN
	IF @UserID = 0
	BEGIN
		RAISERROR(99999, 16, 1, 'User not specified')
	END
	ELSE
	BEGIN
		DELETE FROM dbo.UserRoles WHERE (UserID = @UserID)
		INSERT INTO dbo.UserRoles
			( UserID, ROle )
			SELECT @UserID, StringPart
			FROM [Kernel].[fnSplit](@Roles, ',')
	END
END